<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <h2>数组变化侦测</h2>
    <button v-on:click="fn">btn</button>
    <ul>
      <li v-for="(item, index) in list" :key="index">{{ item }}
        - <button v-on:click="remove(item)">删除</button>
      </li>
    </ul>
  </div>


  <script src="../vue3.js"></script>
  <script>

    // 需要去记住每个数组方法的作用，还有是否改变原数组，返回值是什么
    const {createApp} = Vue;
    createApp({
      data() {
        return {
          list: ["张三", "里斯", "王武"]
        }
      },
      methods: {
        fn() {
          // this.list.push("孙琪");
          this.list = this.list.concat("王八");
        },
        remove(value) {
          // console.log(item);
          this.list = this.list.filter(item => item !== value);
        }
      }
    }).mount("#app");
  </script>
</body>
</html>